﻿using System;
using System.Configuration;

namespace VioletDevelopmentLaboratory.Net.Web.Configuration
{
	public sealed class VWebSection : ConfigurationSection
	{
		[ConfigurationProperty("applicationName", IsRequired = true)]
		public String ApplicationName { get { return (String)base["applicationName"]; } set { base["applicationName"] = value; } }

		[ConfigurationProperty("connectionStringName", DefaultValue = "", IsRequired = true)]
		public string ConnectionStringName { get { return (string)base["connectionStringName"]; } set { base["connectionStringName"] = value; } }

		[ConfigurationProperty("path")]
		public VWebPathElement Path { get { return (VWebPathElement)this["path"]; } set { this["path"] = value; } }

		[ConfigurationProperty("administrator")]
		public VWebAdministratorElement Administrator { get { return (VWebAdministratorElement)this["administrator"]; } set { this["administrator"] = value; } }

		[ConfigurationProperty("controlSettings")]
		public VWebControlSettingsCollection ControlSettings { get { return (VWebControlSettingsCollection)this["controlSettings"]; } set { this["controlSettings"] = value; } }
	}


	public sealed class VWebPathElement : System.Configuration.ConfigurationElement
	{
		[ConfigurationProperty("fileFolder", DefaultValue = @"App_Data\vboard\file", IsRequired = true)]
		public String FileFolder { get { return (String)this["fileFolder"]; } set { this["fileFolder"] = value; } }

		[ConfigurationProperty("memberPictureFolder", DefaultValue = @"App_Data\vboard\member", IsRequired = true)]
		public String MemberPictureFolder { get { return (String)this["memberPictureFolder"]; } set { this["memberPictureFolder"] = value; } }

		[ConfigurationProperty("exceptionLogFolder", DefaultValue = @"App_Data\vboard\log", IsRequired = true)]
		public String ExceptionLogFolder { get { return (String)this["exceptionLogFolder"]; } set { this["exceptionLogFolder"] = value; } }
	}


	public sealed class VWebAdministratorElement : System.Configuration.ConfigurationElement
	{
		[ConfigurationProperty("email", DefaultValue = "", IsRequired = true)]
		public String Email { get { return (String)this["email"]; } set { this["email"] = value; } }

		[ConfigurationProperty("names", DefaultValue = "", IsRequired = true)]
		public String Names { get { return (String)this["names"]; } set { this["names"] = value; } }

		[ConfigurationProperty("role", DefaultValue = "", IsRequired = false)]
		public String Role { get { return (String)this["role"]; } set { this["role"] = value; } }

		[ConfigurationProperty("publicationReport", DefaultValue = false, IsRequired = false)]
		public Boolean PublicationReport { get { return (Boolean)this["publicationReport"]; } set { this["publicationReport"] = value; } }
	}


	public sealed class VWebControlSettingsCollection : System.Configuration.ConfigurationElementCollection
	{
		protected override ConfigurationElement CreateNewElement()
		{
			return new VWebControlSetting();
		}

		protected override Object GetElementKey(ConfigurationElement element)
		{
			return ((VWebControlSetting)element).Property;
		}

		public new VWebControlSetting this[String property]
		{
			get { return (VWebControlSetting)BaseGet(property); }
		}

		public void Add(VWebControlSetting setting)
		{
			BaseAdd(setting, true);
		}

		public void Add(String property, String value)
		{
			BaseAdd(new VWebControlSetting(property, value), true);
		}

		public void Remove(String property)
		{
			BaseRemove(property);
		}

		public void Clear()
		{
			BaseClear();
		}
	}

	public sealed class VWebControlSetting : System.Configuration.ConfigurationElement
	{
		public VWebControlSetting() { }

		public VWebControlSetting(String property, String value)
		{
			this.Property = property;
			this.Value = value;
		}

		[ConfigurationProperty("property", IsRequired = true)]
		public String Property { get { return (String)this["property"]; } set { this["property"] = value; } }

		[ConfigurationProperty("value", IsRequired = true)]
		public String Value { get { return (String)this["value"]; } set { this["value"] = value; } }
	}
}
